#include"mystdio.h"
#include<string.h>
#include<unistd.h>


#define MYFILE "log.txt"

int main()
{
  MY_FILE *fp=my_fpen(MYFILE,"w");
  if(fp==NULL)
  {
    printf("打开文件失败！\n");
    return 1;
  }
  //文件操作
  const char *str="hello my fwrite";
  int cnt=5;
  while(cnt)
  {
    char buff[1024]="";
    snprintf(buff,sizeof(buff),"%s:%d\n",str,cnt--);
    size_t size=my_fwrite(buff,strlen(buff),1,fp);
    sleep(1);
    printf("当前成功写入%lu个字符！\n",size);
  }

  my_fclose(fp);
  return 0;
}
